package com.songVersion.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.songVersion.services.YoutubeInfoManager;
import com.songVersion.services.impl.NestCacheManagerImpl;
import com.songVersion.services.impl.YoutubeInfoManagerImpl;

@SuppressWarnings("serial")
public class AdminServlet extends HttpServlet
{
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException
	{
		resp.setContentType("text/plain");
		String action = req.getParameter("action");
		PrintWriter out = resp.getWriter();
		out.println("action=" + action);
		if ("deleteCache".equals(action))
		{
			YoutubeInfoManager youtubeInfoManager = new YoutubeInfoManagerImpl();
			youtubeInfoManager.deleteAll();
			NestCacheManagerImpl ncm = new NestCacheManagerImpl();
			ncm.deleteAll();
			out.println("all deleted");
		}
		out.close();
	}
}
